<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>中国传媒大学设备预约平台</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="{$projectUrl}/css/admin_style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="{$projectUrl}/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="{$projectUrl}/js/jquery.cycle.all.min.js"></script>
<script type="text/javascript" src="{$projectUrl}/js/globalJsFunction.js"></script>
<script type="text/javascript">
{literal}
$(document).ready(function(){
    $('#slideshow').cycle({
        fx:     'fade',
        speed:  'slow',
        timeout: 3000,
        pager:  '#slider_nav',
        pagerAnchorBuilder: function(idx, slide) {
            // return sel string for existing anchor
            return '#slider_nav li:eq(' + (idx) + ') a';
        }
    });
});
{/literal}
</script>
</head>
<body>
<div class="main">
  <div class="main_resize">
    <div class="main_left">
      {include file=include/headerLogo.html}
      <div class="clr"></div>
      {include file=include/adminLeftMenu.html}
      <div class="clr"></div>
    </div>
    <div class="main_right">
      {include file=include/headerLogin.html}

      <div class="clr" style="background-color:#C63; height:1px;">&nbsp;</div>
      <div>
      {include file=include/adminTopMenu.html}
      </div>
      <div class="clr">
      	<p><img src="{$projectUrl}/images/add2.jpg" width="30px" height="20px"><span style="font-color:#C60; font-size:16px;">添加用户</span>(总个数:{$usernumber})</p>
      	 <!--创建用户-->
                <div id = "create_user_name" style="font-size:14px;">
                <form action="user.php?addTheFirstAdmin={$addTheFirstAdmin}" method="post">
                <input type="hidden" name="action" id="action" value="adduser"/>
                    <table bgcolor="#FFFFFF" width="100%" style="font-size:14px">
                    	<tr>
                    		<td>编号</td>
                    		<td>姓名</td>
                    		<td>预约次数</td>
                    		<td>类型</td>
                    		<td>班级</td>
                    		<td>添加</td>
                    	</tr>
                    	<tr>
                    		<td><input type="text" id="id" name="id" size="14"/></td>
                    		<td><input type="text" id="name" name="name" size="14"/></td>
                    		<td><input type="text" id="booktime" name="booktime" size="10"/></td>
                    		<td>
                    			<select id="type" name="type">
	                        <option value="0" selected="selected">学生</option>
	                        <option value="1">老师</option>
	                        <option value="2">超级管理员</option>
	                        </select>
                    		</td>
                    		<td>
                    			<select id="class" name="class">
	                        <option value="-1" selected="selected"></option>
	                        {foreach from=$classes item=class name=classlist}
	                        <option value="{$class.id}">{$class.name}</option>
	                        {/foreach}
	                        </select>
                    		</td>
                    		<td><input type="image" src="{$projectUrl}/images/add1.jpg" class="button"/></td>
                    	</tr>
                    </table>
                </form>
                </div>
                <!--创建用户结束-->
      </div>

      <!-- 搜索用户并且进行修改 -->
      <div class="clr">
       <!--全部用户的列表-->
                <div>
                	<p>
                		<span style="font-size:12px">
					        	{if $searchNote neq ""}
					        	{$searchNote}
					        	{else}
					        	输入用户ID或者姓名，长度要超过2
					        	{/if}
					        </span>
					        <form id="searchform" name="searchform" method="post" action="user.php">
					        		<input type="hidden" name="action" id="action" value="searchuser"/>
					            <input type="text" class="keywords" id="keyword" name="keyword" maxlength="50" value="{$keyword}"/>
					            <input name="b" type="submit" class="button" value="搜索" />
					        </form>
					        </span>
					        </p>
                <form id="userlist_form" action="user.php?pageIndex={$pageIndex}" method="post" onsubmit="return window.confirm('确定删除？');">
                <input type="hidden" name="action" id="action" value="deleteuser"/>
                    <table width="100%" bgcolor="#FFFFFF" style="font-size:14px;">
                    <tr valign="top"  style="background-color:#C60">
                        <td>({$users|@count})</td>
                        <td>学号</td>
                        <td>名字</td>
                        <td>可用预约</td>
                        <td>班级</td>
                        <td>类型</td>
                        <td>编辑</td>
                    </tr>
                    {foreach from=$users item=user name=userlist}
                    <tr valign="top"  onmouseout="this.style.backgroundColor=''"onmouseover="this.style.backgroundColor='#AAAAAA'">
                        <td><input type="checkbox" id="user[]" name="user[]" value="{$user.id}"/></td>
                        <td>{$user.id}</td>
                        <td><span style="font-size:12px;" title="{$user.name}">{$user.name|truncate:40:".."}</span></td>
                        <td>{$user.booktime}</td>
                        <td><span style="font-size:12px;">{$user.classid}</span></td>
                        <td>{if $user.level eq 0}<span style="font-size:12px;color:#66CC66;">学生</span>
                            {elseif $user.level eq 1}<span style="font-size:12px;color:#C60;">老师</span>
                            {else}<span style="font-size:12px;color:#EE000;">未确定</span>
                            {/if}</td>
                        <td><a href="user.php?action=edit&id={$user.id}&pageIndex={$pageIndex}#editUserDiv">编辑</a></td>
                    </tr>
                    {/foreach}


                    <tr><td align="right" colspan="2">
                        <input type="button" value="全选" onclick="chkall('userlist_form')" />
                        <input type="reset" value="不选" />
                        </td>
                        <td align="left" colspan="3">
                        <input type="submit" value="删除选中"/>
                        </td>
                    </tr>
                     <tr>
                    <td colspan="5" align="center">
                    <!-- 分页 -->
                        <a href="user.php?pageIndex={$leftPageIndex}">&lt;</a>

                    {section start=$leftMostPageIndex loop=$pageIndex step=1 name=pagesection}
                    <a href="user.php?pageIndex={$smarty.section.pagesection.index}">
                    {$smarty.section.pagesection.index}&nbsp;&nbsp;
                    </a>
                    {/section}
                    <span style="font-size:18px;"><Strong><bold>{$pageIndex}</bold></Strong>&nbsp;</span>
                    {section start=$pageIndex+1 loop=$rightMostPageIndex+1 step=1 name=rightpagesection}
                    <a href="user.php?pageIndex={$smarty.section.rightpagesection.index}">
                    {$smarty.section.rightpagesection.index}&nbsp;&nbsp;
                    </a>
                    {/section}

                    <a href="user.php?pageIndex={$rightPageIndex}">&gt;</a>
                    <!-- 分页 -->
                    </td>
                    </tr>
                    </table>
                </form>
                </div>
                <!--全部用户的列表-->
      </div>
      <!-- 搜索用户并且进行修改 结束-->
      <div class="clr"></div>
      <!-- 编辑用户 -->
      {if $editUser.id neq ''}
      <div class="clr" id="editUserDiv">
      	<p><img src="{$projectUrl}/images/img_1.jpg" width="30px" height="30px"><span style="font-color:#C60; font-size:16px;">编辑用户</span></p>
                <div id = "modify_user" style="font-size:14px;">
                <form action="user.php?id={$editUser.id}&pageIndex={$pageIndex}#editUserDiv" method="post">
                <input type="hidden" name="action" id="action" value="modifyuser"/>
                <input type="hidden" name="userid" id="userid" value="{$editUser.id}"/>
                    <table bgcolor="#FFFFFF" width="100%" style="font-size:12px;">
                    	<tr>
                    		<td>编号</td><td>{$editUser.id}</td>
                    	</tr>
                    	<tr>
                    		<td>密码</td><td><a href="user.php?action=resetPassword&pageIndex={$pageIndex}&id={$editUser.id}#editUserDiv">点击重置为默认密码</a></td>
                    	</tr>
                    	<tr>
                    		<td>姓名</td><td><input type="text" id="name" name="name" size="14" value="{$editUser.name}"/></td>
                    		</tr>
                    	<tr>
                    		<td>预约次数</td><td><input type="text" id="booktime" name="booktime" size="10" value="{$editUser.booktime}"/></td>
                    		</tr>
                    	<tr>
                    		<td>类型</td>
                    		<td>
                    			<select id="type" name="type">
	                        <option value="0" {if $editUser.level eq 0}selected="selected"{/if}>学生</option>
	                        <option value="1" {if $editUser.level eq 1}selected="selected"{/if}>老师</option>
	                        </select>
                    		</td>
                    		</tr>
                    	<tr>
                    		<td>班级</td>
                    		<td>
                    			<select id="class" name="class">
                    				<option value="-1" {if $editUser.classid eq ""}selected="selected"{/if}></option>
	                        {foreach from=$classes item=class name=classlist}
	                        <option value="{$class.id}" {if $class.id eq $editUser.classid}selected="selected"{/if}>{$class.name}</option>
	                        {/foreach}
	                        </select>
                    		</td>
                    		</tr>
                    	<tr>
                    		<td>email:</td><td><input type="text" id="email" name="email" size="20" value="{$editUser.email}"/></td>
                    		</tr>
                    	<tr>
                    		<td>电话</td><td><input type="text" id="phone" name="phone" size="20" value="{$editUser.phone}" onkeyup="value=value.replace(/[^\d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/></td>
                    		</tr>
                    	<tr valign="top">
                    		<td>介绍</td><td><textarea type="text" id="info" name="info" rows="2" cols="20">{$editUser.info}</textarea></td>
                    		</tr>
                    	<tr>
                    		<td>创建时间</td><td>{$editUser.createtime}</td>
                    	</tr>
                    <tr>
                    		<td>保存</td><td><input type="image" src="{$projectUrl}/images/save.jpg" class="button"/></td>
                    	</tr>
                    </table>
                </form>
                </div>
      </div>
      {/if}
      <!-- 编辑用户结束 -->
      
      <!-- 编辑用户课程 -->
      {if $editUser.id neq ''}
      <div class="clr" id="editUserCourseDiv" >
      	{if $addUserCourseNotice neq ''}
      	<p style="color:red"><Strong>{$addUserCourseNotice}</Strong></p>
      	{/if}
      	<p><img src="{$projectUrl}/images/img_1.jpg" width="30px" height="30px"><span style="font-color:#C60; font-size:16px;">编辑所属课程({$userCourses|@count})</span></p>
                <div id = "modify_user" style="font-size:14px;">
                <form action="user.php?id={$editUser.id}&pageIndex={$pageIndex}#editUserCourseDiv" method="post">
                <input type="hidden" name="action" id="action" value="addUserCourse"/>
                <input type="hidden" name="userid" id="userid" value="{$editUser.id}"/>
                    <table bgcolor="#FFFFFF" width="100%" style="font-size:14px;">
                    	<tr>
                    		<td>{if $editUser.level eq 0}学生{else}老师{/if}:{$editUser.name}({$editUser.id})</td>
                    		<td>课程:
                    			<select id="courseid" name="courseid">
	                        {foreach from=$courses item=course name=courseslist}
	                        <option value="{$course.id}">{$course.name}</option>
	                        {/foreach}
	                        </select>
                    		</td>
                    		<td>预约次数:<input type="text" id="booktime" name="booktime" size="10" value="{$defaultBooktime}"/>
                    		</td>
                    		<td><input type="image" src="{$projectUrl}/images/add1.jpg" class="button"/>
                    			</td>
                    	</tr>
                    </table>
                </form>
                </div>
      </div>
      {/if}
      <!-- 编辑用户结束 -->
      
      
      {if $editUser.id neq ''}
      <!-- 编辑用户与课程的对应信息 -->
      <div class="clr" id="saveremoveusercoursediv"> 
      	<table width="100%" bgcolor="#FFFFFF" style="font-size:14px;">
                    <tr valign="top"  style="background-color:#C60">
                    		<td>创建时间</td>
                        <td>课程名字</td>
                        <td>预约次数</td>
                        <td>保存</td>
                        <td>删除</td>
                    </tr>
                    {foreach from=$userCourses item=userCourse name=userCourseslist}
                    <tr valign="top"  onmouseout="this.style.backgroundColor=''"onmouseover="this.style.backgroundColor='#AAAAAA'">
                    		<form action="user.php?id={$editUser.id}&pageIndex={$pageIndex}#saveremoveusercoursediv" method="post">
                    			<input type="hidden" name="courseId" value="{$userCourse.cid}" />
                    			<input type="hidden" name="userId" value="{$editUser.id}" />
                    			<input type="hidden" name="action" value="saveUserCourseBooktime" />
                        <td>{$userCourse.createtime}</td>
                        <td>{$userCourse.courseName}</td>
                        <td><input type="text" name="booktime" id="booktime" value="{$userCourse.booktime}" /></td>
                        <td><span style="font-size:12px;"><input type="image" src="{$projectUrl}/images/save.jpg" class="button"/></span></td>
                        <td><a href="user.php?action=removeusercourse&id={$editUser.id}&courseid={$userCourse.cid}&pageIndex={$pageIndex}#saveremoveusercoursediv"><span style="color:#red">删除</span></a></td>
                    	</form>
                    </tr>
                    {/foreach}
                    </table>	
      </div>
      <!-- 编辑用户与课程的对应信息 end-->
      {/if}

    </div>
    
    <!-- 展示用户的课程列表 -->
    <div class="clr">
    	
    </div>
  </div>
  <div class="footer">
    {include file=include/footer.html}
  </div>
</div>
<div align=center></div></body>
</html>
